package top.fengyulou.qmy.advice;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;
import top.fengyulou.config.SysConfig;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 控制器通知
 */
@Slf4j
@ControllerAdvice("top.fengyulou.qmy.controller")
public class MyControllerAdvice {

    @Resource
    private SysConfig sysConfig;

    /**
     * 设置静态域名
     *
     * @return
     */
    @ModelAttribute("staticUrl")
    public String staticUrl() {
        return sysConfig.getDomainName();
    }

    /**
     * 版权时间
     *
     * @return
     */
    @ModelAttribute("copyrightTime")
    public int copyrightTime() {
        /*2020年制作的系统*/
        return DateUtil.year(new Date());
    }
}
